<template lang="pug">
  .app-url-base(@click="downloadApp()", v-if="is_iphone")
    .icon
      img(:src="site_info.app_icon_url")
    .download-app 下载优惠券APP
</template>
<script>
import SiteInfo from '../helpers/site_info'
import Window from '../helpers/window'
import Settings from '../../settings'

export default {
  name: 'AppUrl',
  computed: {
    site_info () {
      return SiteInfo.get()
    },
    is_iphone () {
      if (Window.isIphone()) {
        return true
      } else {
        return false
      }
    }
  },
  methods: {
    downloadApp () {
      if (Window.isWeibo()) {
        window.location = Settings.app.weibo
      } else {
        window.location = Settings.app.default
      }
    }
  }
}
</script>
<style lang="sass">
@import '../styles/color.sass';
.app-url-base
  background: $gray-bg
  padding: 5px 32px
  display: flex
  flex-direction: row
  justify-content: space-between
  align-items: center
  font-size: .9em
  .icon
    img
      height: 50px
  .open-in-app
    border: $red 1px solid
    color: $red
    border-radius: 3px
    line-height: 32px
    padding: 0px 20px
  .download-app
    background: $red
    color: $white
    padding: 0px 20px
    line-height: 36px
    border-radius: 3px
    cursor: pointer
</style>
